#include <iostream>
#include<cstdio>
using namespace std;
int n, l, r;
int main(int argc, char** argv) {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d %d %d",&n, &l, &r);
	if(r%n==n-1)
		printf("%d", n-1);
	else if(r/n*n-1>=l)
		printf("%d", n-1);
	else
		printf("%d", r%n);
	return 0;
}
